package org.chinacareer.position.config;

import java.util.Properties;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingFactory;
import com.alibaba.nacos.api.naming.NamingService;

import lombok.Data;

/**
 * @author jerry
 * @ClassName:  MyPollingServerListUpdater   
 * @Description:TODO(描述这个类的作用)   
 * @date 2022年12月1日 下午3:09:10
 */
@Configuration
@Data
public class NacosNamingConfig {

	@Value("${spring.cloud.nacos.server-addr}")
	private String serverAddr;
	@Value("${spring.cloud.nacos.discovery.namespace}")
	private String namespace;
	@Value("${spring.cloud.nacos.discovery.group}")
	private String group;

	private static NamingService namingService;

	@Bean(name = "namingService")
	public NamingService get() throws NacosException {
		Properties properties = System.getProperties();
		properties.setProperty("serverAddr", serverAddr);
		properties.setProperty("namespace", namespace);
		namingService = NamingFactory.createNamingService(properties);
		return namingService;
	}

}
